﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Net.Mail;

namespace cbelo.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult Contact()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Contact(int? id)
        {
            ViewData["Message"] = "Mensagem enviada com sucesso!";

            String from = Request.Params["email"];
            String mensagem = "Nome: " + Request.Params["nome"] + "\nMensagem: " +Request.Params["mensagem"];

            String to = "raphael.meloni@gmail.com";

            MailMessage message = new MailMessage(from, to, "Contato", mensagem);

            try
            {
                SmtpClient client = new SmtpClient("smtp.gmail.com");
                client.Send(message);
            }
            catch(System.Net.Mail.SmtpException e)
            {
            }

            return View();
        }
        
    }
}
